package com.learn.step03_functions

/**
 *
 *
 * @author: hbliy
 * @date: 2025/7/8 15:37
 */
fun main(args: Array<String>) {
    functionIntro()

    sum(3, 5)

    val result = sumAndReturn(3, 5)
    println(result)


    privateFun()

    defaultParam(20)

    val res = formatHealthStatus(3, true)
    println(res)

    sum(b=3, a=4)

//    shouldReturnAString()
    `**~prolly not a good idea!~**`()
}


fun functionIntro() {
    println("Sample fun")
}

fun sum(a: Int, b: Int) {
    println(a + b)
}

fun sumAndReturn(a: Int, b: Int): Int {
    return a + b
}

private fun privateFun() {
    println("private fun")
}

fun defaultParam(a: Int, b: Int = 10) {
    println(a + b)
}

/**
 * 单表达式函数语法
 */
private fun formatHealthStatus(healthPoints: Int, isBlessed: Boolean) =
    when (healthPoints) {
        100 -> "is in excellent condition!"
        in 90..99 -> "has a few scratches."
        in 75..89 -> if (isBlessed) {
            "has some minor wounds, but is healing quite quickly!"
        } else {
            "has some minor wounds."
        }

        in 15..74 -> "looks pretty hurt."
        else -> "is in awful condition!"
    }


fun sumAndReturnSample(a: Int, b: Int) = a + b


fun shouldReturnAString(): String {
    TODO("implement the string building functionality here to return a string")
}


fun `**~prolly not a good idea!~**`() {
    println("This is a function with a name that starts and ends with two special characters.")
}
